<?php
/**
 *
 * 
 * @author David Christian Liedle <david.liedle@gmail.com>
 * @link   http://nmox.org/
 *
 */

function redirect($url){
	// TODO: log redirection
	
	// redirect
	header('Location: '.$url);
}

if( $_GET['url'] ){
	
	switch( $_GET['url'] ){
		case 'google.com':
			redirect('http://google.com/');
			break;
		case 'yahoo.com':
			redirect('http://yahoo.com/');
			break;
		case 'nmox.org':
			redirect('http://nmox.org/');
			break;
		default:
			echo '<p style="color: red">Sorry, that URL is not OK.</p>';
	}
	
} else {
	
	echo 'No redirect URL specified. Use [
	<code><strong>redirect.php?url=</strong></code> ]<br />
	to specify an approved address.';
	
}
